home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / PRINTING.SWG / 0007_PRINTER1.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  71 lines

  1. {
  2. I am writing a Program that Uses the Printer to (whatelse?) print
  3. out a report.  Now, the problem that I am having is that the Printer
  4. Function in TP 6.0 (ie Writeln (lst,'BLA BLA BLA');) Dosn't
  5. check For errors (if the Printer is not on, or is not online)
  6. basicaly I need something that weill check and give out the
  7. famous line ('Printer not Ready (A)bort (R)etry')
  8.  
  9.  
  10. Your're in luck, I just got a new Printer and started writing routines to
  11. control it (TFDD etc..). These are probably the most important ones:
  12.  
  13.  
  14.  
  15. { note: This routines are not throughly tested on Various Printers.}
  16. {       Thus it may of may not work on your Type of Printer.       }
  17. {       But, as a rule, experiment With it and have fun............}
  18.  
  19. Uses
  20.   Dos;
  21.  
  22. Functio PrinterOutofPaper( Port : Byte): Boolean;
  23. Var
  24.   Regs : Registers;
  25. begin
  26.   Regs.AH := $02;
  27.   Regs.DX := Port;          { 0=LPT1,  1=LPT2,  2=LPT3 }
  28.   Intr($17, Regs);          { Print Service Please }
  29.   PrinterOutofPaper := (Regs.AH and $20 = $20)
  30. end;
  31.  
  32. Function PrinterReady( Port : Byte): Boolean;
  33. Var
  34.   Regs : Registers;
  35. begin
  36.   With Regs Do
  37.   begin
  38.     AH := $02;
  39.     DX := Port;          { 0=LPT1,  1=LPT2,  2=LPT3 }
  40.     Intr($17, Regs)
  41.     PrinterReady := (AH and $80 = $80) and       { Printer Busy?   }
  42.                     (AH and $10 = $10) and       { Printer Online? }
  43.                     (AH and $08 = $00)           { Printer Error?  }
  44.   end;
  45. end;
  46.  
  47. Procedure PrintChar(Port: Byte; Ch: Char);
  48. Var
  49.   Regs : Registers;
  50. begin
  51.   With Regs Do
  52.   begin
  53.     AL := ord(Ch);             { Char to print            }
  54.     DX := Port;                { 0=LPT1,  1=LPT2,  2=LPT3 }
  55.     AH := $00;                 { Print Char Service       }
  56.     Intr($17, Regs);           { Call Bios                }
  57.   end
  58. end;
  59.  
  60. Procedure BootPrinter( Port: Byte);
  61.  { Initializes IBM- or EPSON- Compatible Printer  }
  62.  { Other Printers may not understand this command }
  63.  { and may produce unwanted results               }
  64. Var
  65.   Regs : Registers;
  66. begin
  67.   Regs.DX := Port;                { 0=LPT1,  1=LPT2,  2=LPT3 }
  68.   Regs.AH := $01;
  69.   Intr($17, Regs)
  70. end;
  71.